Move Objects within module

Morning All,

Please forgive my somewhat straightforward question...

I am trying to move objects that are littered within a module to beneath a specific object depending on an enumerated attribute value:

I've tried to declare object p as the target object for the move command.

Module m = current
Object p = object(142)
Object o
string s
for o in m do {
+ s = o."Site Type"+
+ if (s == "Equipment Only")+
+ {+
+ move (o, last below p)+
+ }+
}

Error received is: null Object parameter was passed into argument position 2

I think it's because of the way I am setting object P. It's a section heading and I want all objects that satisfy the conditional statement to be moved below it. I've used 'last' to keep alphabetical order.

I'm sure it's something simple but I just can't get the syntax right..

Thanks in advance for your help...

N
SystemAdmin - Tue Feb 26 05:15:28 EST 2013

Re: Move Objects within module
llandale - Wed Feb 27 14:45:48 EST 2013

First off...

  • if (null p) {warningBox("object #142 not visible or doesn't exist"); halt}
  • if (o == p) continue // Lets not try to move o last below itself


You have a structural problem. The "for o in m do" loop is actually this:

 

o = top(m)
while(!null o)
{ deal with o
  o = next(o)
}


So if you move o, the original "next(o)" is no longer the current "next(o)", and you will either bypass a lot of objects or get into a loop.

 

 

Skip skpObjs = create()
int  Sequence = 0
for o in m do {put(skpObjs, Sequence++, o)}
for o in skpObjs do
{  body of loop
}
delete(skpObjs)


-Louie

 

Re: Move Objects within module
SystemAdmin - Thu Mar 07 03:50:30 EST 2013

llandale - Wed Feb 27 14:45:48 EST 2013

First off...

  • if (null p) {warningBox("object #142 not visible or doesn't exist"); halt}
  • if (o == p) continue // Lets not try to move o last below itself


You have a structural problem. The "for o in m do" loop is actually this:

 

o = top(m)
while(!null o)
{ deal with o
  o = next(o)
}


So if you move o, the original "next(o)" is no longer the current "next(o)", and you will either bypass a lot of objects or get into a loop.

 

 

Skip skpObjs = create()
int  Sequence = 0
for o in m do {put(skpObjs, Sequence++, o)}
for o in skpObjs do
{  body of loop
}
delete(skpObjs)


-Louie

 

Thank you Louie, pretty obvious flaw in the program flow once it is pointed out to me...

first time I have used skip lists too!!!

All good now...:)

Re: Move Objects within module
llandale - Thu Mar 07 14:38:54 EST 2013

SystemAdmin - Thu Mar 07 03:50:30 EST 2013
Thank you Louie, pretty obvious flaw in the program flow once it is pointed out to me...

first time I have used skip lists too!!!

All good now...:)

Staging this stuff in Skip Lists is routine whenever you figure to change the existence or order of the thing. It is also required in the rare cases you have the SAME nested structure:

  • for o1 in m do
    • whatever
    • for o2 in m do

The second "m" loop will disrupt the 1st.

I have a massive library and can and do get these double nested loops; so my main programs routinely stage in Skip lists even if there does not appear to be a good reason.

The Sequencer just gets them evaluated in the original order.

-Louie